package com.fulong.service.impl;

import com.fulong.entity.DeviceLendRecordEntity;
import com.fulong.entity.DeviceManageInfoEntity;
import com.fulong.entity.UserMsgInfoEntity;
import com.fulong.service.UserMsgInfoService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fulong.common.utils.PageUtils;
import com.fulong.common.utils.Query;

import com.fulong.dao.UserMsgInfoDao;
import com.fulong.entity.UserMsgInfoEntity;
import com.fulong.service.UserMsgInfoService;


@Service("userMsgInfoService")
public class UserMsgInfoServiceImpl extends ServiceImpl<UserMsgInfoDao, UserMsgInfoEntity> implements UserMsgInfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<UserMsgInfoEntity> page = this.page(
                new Query<UserMsgInfoEntity>().getPage(params),
                new QueryWrapper<UserMsgInfoEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public boolean createMsgByApprover(DeviceLendRecordEntity deviceLendRecord){
        UserMsgInfoEntity userMsgInfoEntity = new UserMsgInfoEntity();
        userMsgInfoEntity.setSenderid(deviceLendRecord.getUserid());
        userMsgInfoEntity.setReceiverid(deviceLendRecord.getApproverid());
        userMsgInfoEntity.setMsgcontent(deviceLendRecord.getMsg());
        userMsgInfoEntity.setStatus(0);
        userMsgInfoEntity.setMsgtype("0");
        userMsgInfoEntity.setCreatdate(new Date());
        boolean save = save(userMsgInfoEntity);
        return save ;
    }

}